package dongchel.vrp.immunes;

import java.util.ArrayList;
import java.util.List;

import dongchel.vrp.entity.Solution;
import dongchel.vrp.general.CompareObject;

public class Clone {

	int cloneSize = 25;  //for clone10Times

	public List<Solution> clone10Times(List<Solution> clonePopulation, List<CompareObject> compareObjectList) {
		for(int i=0;i<cloneSize;i++) {
			Solution solu = (Solution)compareObjectList.get(i).getObject();
			int j = 0;
			while(j<24){
				clonePopulation.add((Solution)solu.clone());
				j++;
			}
		}
		return clonePopulation;
	}
	public List<Solution> cloneByAffinity(List<Solution> clonePopulation, List<Solution> initialPopulation, List<Double> accumulateAffi) {
/*		System.out.println("-------------");
		System.out.println();
		int[] repeatTimes = new int[100];*/
		int count = 0;
		while(count<600) {
			int j = 0;
			double rand = Math.random();
			for(int i=0;i<accumulateAffi.size();i++) {
				if(rand<accumulateAffi.get(i)) {
					j = i-1;
					break;
				}
			}
			/*System.out.println("j:"+j+"   accumAffi(j+1)-(j): "+(accumulateAffi.get(j+1)-accumulateAffi.get(j)));
			repeatTimes[j]++;
			System.out.println("repeatTimes: "+repeatTimes[j]);*/
			clonePopulation.add(initialPopulation.get(j));
			count++;
		}
		return clonePopulation;
	}
}
